package com.juyu.miliao.api.rabbitMQ;

import com.alibaba.fastjson.JSONObject;
import com.juyu.miliao.common.constant.enumMQKey.EnumTypeMQ;
import com.juyu.miliao.common.domain.CommonHead;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class UserLoginRobotMessageRabbitMq {

    @Resource
    private AmqpTemplate amqpTemplate;

    public void userLoginRobotMessageMQ(long userId, CommonHead commonHead){
        JSONObject json = new JSONObject();
        json.put("appPackageId",commonHead.getAppPackageId());
        json.put("channel",commonHead.getChannel());
        json.put("phoneSystem",commonHead.getPhoneSystem());
        json.put("userId",userId);
        json.put("versionNum",commonHead.getVersionNum());

        amqpTemplate.convertAndSend(EnumTypeMQ.User_Login_Robot_Message.exchange,
                EnumTypeMQ.User_Login_Robot_Message.routingKey,json.toString());
    }
}
